import path from 'path'
import express from 'express'
import cookieParser from 'cookie-parser'
import logger from 'morgan'
import cors from 'cors'
import { mailQueueHandle } from '@/mq'
import routers from './config/routers'

// 消息队列
mailQueueHandle()

const app = express()

// 中间件
app.use(logger('dev'))
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(express.static(path.join(__dirname, '../public')))
app.use(cors())

// 路由配置
app.use(routers)

export default app
